﻿$(document).ready(function () {
    $("#txtComplete").autocomplete("tools/search_ajax.ashx", {
        minChars: 0,
        width: 310,
        matchContains: false,
        autoFill: true,
        max: 10,
        //需要把data转换成json数据格式
        parse: function (data) {
            return $.map(eval(data), function (row) {
                return {
                    data: row,
                    value: row.title,
                    result: row.title //+ " <" + row.to + ">"
                }
            });
        },
        formatItem: function (data, i, total) {

            return i + "/" + total + ": \"" + data.title; //+ "\" [" + row.to + "]"

        },
        formatMatch: function (data, i, total) {
            return data.title; // + " " + row.to
        },
        formatResult: function (data, value) {
            return data.title; //row.to
        }
    });
});